var api = require('../../utils/api.js');
var app = getApp();
Page({

    /**
     * 页面的初始数据
     */
    data: {
        tops: 32,
        orders:[],
        indx:''
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {
        var infos = wx.getSystemInfoSync();
        console.log(infos);
        console.log(infos.statusBarHeight);
        var that=this;


        this.setData({
            tops: infos.statusBarHeight + 4
        })


        //关联项目
        api.post({
            url: 'icons/getallicons',
            data: '',
            success: data => {
                that.setData({
                    orders:data.data
                })
            }
        })

    },

    goindex() {
        wx.navigateBack();
    },

    getnewicons(ret){
        console.log(ret)

        var indx=ret.currentTarget.dataset.i;
        var list=this.data.orders

        this.setData({
            indx:list[indx].id,
            icon_t:list[indx].name,
            icon_id:list[indx].id
        })

    },

    backtop(){

        var icon_t=this.data.icon_t;
        var icon_id=this.data.icon_id;

        let pages = getCurrentPages();   
        let prevPage = pages[pages.length - 2];     //-2为上一级页面  


        prevPage.setData({
            icon_id: icon_id,
            icon_t:icon_t         
        })
        wx.navigateBack({
          delta: 1        
        })
    

    }
})